package com.tengju.data.domain.model.report;

import com.tengju.data.domain.model.user.StarLevelEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * @author chenhang
 * @Date 2020/12/22
 */
@Component
public class AchievementBonusCalConfig {

    public static Double SPECIAL_STAR_FIRST_YEAR_LIMIT_DEBATE;
    public static Double SPECIAL_STAR_AFTER_YEAR_LIMIT_DEBATE;
    public static int SPECIAL_STAR_YEAR_MONTH_THRESHOLD;
    public static BigDecimal ACHIEVEMENT_BONUS_THRESHOLD;
    public static Double STAR_BONUS_DEBATE_LIMIT_NONE;
    public static Double STAR_BONUS_DEBATE_LIMIT_ONE;
    public static Double STAR_BONUS_DEBATE_LIMIT_TWO;
    public static Double STAR_BONUS_DEBATE_LIMIT_THREE;
    public static Double STAR_BONUS_DEBATE_LIMIT_FOUR;
    public static Double STAR_BONUS_DEBATE_LIMIT_EC;
    public static Double STAR_BONUS_DEBATE_LIMIT_SEC;
    public static Double STAR_BONUS_DEBATE_LIMIT_EEC;

    public static Double getSpecialStarBonusDebateLimit(int month) {
        if (month >= SPECIAL_STAR_YEAR_MONTH_THRESHOLD) {
            return SPECIAL_STAR_AFTER_YEAR_LIMIT_DEBATE;
        }
        return SPECIAL_STAR_FIRST_YEAR_LIMIT_DEBATE;
    }

    public static Double getStarBonusDebateLimit(StarLevelEnum starLevel) {
        if (starLevel == null) {
            return AchievementBonusCalConfig.STAR_BONUS_DEBATE_LIMIT_NONE;
        }
        switch (starLevel) {
            case CITY_STAR_ONE:
                return AchievementBonusCalConfig.STAR_BONUS_DEBATE_LIMIT_ONE;
            case CITY_STAR_TWO:
                return AchievementBonusCalConfig.STAR_BONUS_DEBATE_LIMIT_TWO;
            case CITY_STAR_THREE:
                return AchievementBonusCalConfig.STAR_BONUS_DEBATE_LIMIT_THREE;
            case CITY_STAR_FOUR:
                return AchievementBonusCalConfig.STAR_BONUS_DEBATE_LIMIT_FOUR;
            case EC:
                return AchievementBonusCalConfig.STAR_BONUS_DEBATE_LIMIT_EC;
            case SEC:
                return AchievementBonusCalConfig.STAR_BONUS_DEBATE_LIMIT_SEC;
            case EEC:
                return AchievementBonusCalConfig.STAR_BONUS_DEBATE_LIMIT_EEC;
            default:
                return AchievementBonusCalConfig.STAR_BONUS_DEBATE_LIMIT_NONE;
        }
    }

    @Value("${achievement-bonus.config.special-user.first-year-debate-limit}")
    public  void setSpecialStarFirstYearLimitDebate(Double specialStarFirstYearLimitDebate) {
        SPECIAL_STAR_FIRST_YEAR_LIMIT_DEBATE = specialStarFirstYearLimitDebate;
    }

    @Value("${achievement-bonus.config.special-user.after-year-debate-limit}")
    public  void setSpecialStarAfterYearLimitDebate(Double specialStarAfterYearLimitDebate) {
        SPECIAL_STAR_AFTER_YEAR_LIMIT_DEBATE = specialStarAfterYearLimitDebate;
    }

    @Value("${achievement-bonus.config.special-user.month-threshold}")
    public  void setSpecialStarYearMonthThreshold(int specialStarYearMonthThreshold) {
        SPECIAL_STAR_YEAR_MONTH_THRESHOLD = specialStarYearMonthThreshold;
    }

    @Value("${achievement-bonus.config.achievement-threshold}")
    public  void setAchievementBonusThreshold(BigDecimal achievementBonusThreshold) {
        ACHIEVEMENT_BONUS_THRESHOLD = achievementBonusThreshold;
    }

    @Value("${achievement-bonus.config.star-debate-limit.none}")
    public  void setStarBonusDebateLimitNone(Double starBonusDebateLimitNone) {
        STAR_BONUS_DEBATE_LIMIT_NONE = starBonusDebateLimitNone;
    }

    @Value("${achievement-bonus.config.star-debate-limit.city-star-one}")
    public  void setStarBonusDebateLimitOne(Double starBonusDebateLimitOne) {
        STAR_BONUS_DEBATE_LIMIT_ONE = starBonusDebateLimitOne;
    }

    @Value("${achievement-bonus.config.star-debate-limit.city-star-two}")
    public  void setStarBonusDebateLimitTwo(Double starBonusDebateLimitTwo) {
        STAR_BONUS_DEBATE_LIMIT_TWO = starBonusDebateLimitTwo;
    }

    @Value("${achievement-bonus.config.star-debate-limit.city-star-three}")
    public  void setStarBonusDebateLimitThree(Double starBonusDebateLimitThree) {
        STAR_BONUS_DEBATE_LIMIT_THREE = starBonusDebateLimitThree;
    }

    @Value("${achievement-bonus.config.star-debate-limit.city-star-four}")
    public  void setStarBonusDebateLimitFour(Double starBonusDebateLimitFour) {
        STAR_BONUS_DEBATE_LIMIT_FOUR = starBonusDebateLimitFour;
    }

    @Value("${achievement-bonus.config.star-debate-limit.ec}")
    public  void setStarBonusDebateLimitEc(Double starBonusDebateLimitEc) {
        STAR_BONUS_DEBATE_LIMIT_EC = starBonusDebateLimitEc;
    }

    @Value("${achievement-bonus.config.star-debate-limit.sec}")
    public  void setStarBonusDebateLimitSec(Double starBonusDebateLimitSec) {
        STAR_BONUS_DEBATE_LIMIT_SEC = starBonusDebateLimitSec;
    }

    @Value("${achievement-bonus.config.star-debate-limit.eec}")
    public  void setStarBonusDebateLimitEec(Double starBonusDebateLimitEec) {
        STAR_BONUS_DEBATE_LIMIT_EEC = starBonusDebateLimitEec;
    }
}
